

import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class lq592 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int res = 0;
        for (int i = 1; i <= 2020; i++) {
          // 移花接木
          int n = i;
          while (n > 0) {
            // 遍历每一位
            if ((n % 10) == 2)  res++;
            n /= 10;
          }
        }
        System.out.println(res);
        scan.close();
    }
}
